//
//  GFShareSDKManager.m
//  GFShareSDK
//
//  Created by 胡林虎 on 2017/8/5.
//  Copyright © 2017年 胡林虎. All rights reserved.
//

#import "GFShareSDKManager.h"
static NSString * const WX_APPKEY = @"wx9c464c406f732ae2";
static NSString * const WX_PAYKEY = @"wx83e0e8875b999b89";

@implementation GFShareSDKManager

-(BOOL)isInstalledQQApp {

    BOOL isInstalled = [QQApiInterface isQQInstalled];
    return isInstalled;
}

-(BOOL)isInstalledWXApp {
    
    BOOL isInstalled = [WXApi isWXAppInstalled];
    return isInstalled;

}

-(BOOL)isInstalledWeiboApp {

    BOOL isInstalled = [WeiboSDK isWeiboAppInstalled];
    return isInstalled;
}
-(id)registerActivePlatforms:(NSArray *)activePlatforms {
    
    //lx change
    [ShareSDK registerActivePlatforms:@[
                                        @(SSDKPlatformTypeSinaWeibo),
                                        @(SSDKPlatformTypeWechat),
                                        @(SSDKPlatformTypeQQ),
                                        ]
                             onImport:^(SSDKPlatformType platformType)
     {
         switch (platformType)
         {
                 case SSDKPlatformTypeWechat:
                 //                 [ShareSDKConnector connectWeChat:[WXApi class]];
                 
                 
                 [ShareSDKConnector connectWeChat:[WXApi class] delegate:self];
                 break;
                 case SSDKPlatformTypeQQ:
                 [ShareSDKConnector connectQQ:[QQApiInterface class] tencentOAuthClass:[TencentOAuth class]];
                 break;
                 case SSDKPlatformTypeSinaWeibo:
                 [ShareSDKConnector connectWeibo:[WeiboSDK class]];
                 break;
             default:
                 break;
         }
     }
                      onConfiguration:^(SSDKPlatformType platformType, NSMutableDictionary *appInfo)
     {
         
         switch (platformType)
         {
                 case SSDKPlatformTypeSinaWeibo:
                 //设置新浪微博应用信息,其中authType设置为使用SSO＋Web形式授权
                 [appInfo SSDKSetupSinaWeiboByAppKey:@"1079927903"
                                           appSecret:@"8e9ea3b8fed3fca16ef22d1e368edee9"
                                         redirectUri:@"https://api.weibo.com/oauth2/default.html"
                                            authType:SSDKAuthTypeSSO];
                 break;
                 case SSDKPlatformTypeWechat:
                 [appInfo SSDKSetupWeChatByAppId:WX_APPKEY
                                       appSecret:@"50fefcf139720d63f85f9f8afed75468"];
                 break;
                 case SSDKPlatformTypeQQ:
                 [appInfo SSDKSetupQQByAppId:@"1106006134"
                                      appKey:@"PIjtUOT40X9diNTM"
                                    authType:SSDKAuthTypeSSO];
                 break;
             default:
                 break;
         }
     }];
    
    //单独注册微信【[WXApi isWXAppInstalled]】 此方法获取不到
    //注册支付appID(国美保险)
    [WXApi registerApp:WX_PAYKEY];
    [WeiboSDK registerApp:@"1079927903"];
    
    return nil;
}

@end
